import { observable, action, makeObservable } from "mobx";
import { PageDateSelect } from '@/types/pages/enum'
import { IPurchaseGoodFull } from "@/types/pages/purchase/interface";
import {getMaterialPieChart,getMaterialColumnChart,getMaterialLineChart,getPurchaseNumChart,getPurchaseNumData,getPurchaseTypePieChart} from "@/api/purchaseGoods";
import { IStore } from "@/types/pages/base";

/**
 * class PurchaseGood
 * 物资采购
 */
class PurchaseGood implements IStore<IPurchaseGoodFull>  {
    @observable screenData: IPurchaseGoodFull= {purchaseNum:{}, purchaseNumPie:{}, materialPie:{}, purchaseTypePie:{},materialTop10Column:{}, priceTop10Column:{}}
    constructor() {
      makeObservable(this)
  }
    /**
     *
     * @param type 日期选择函数
     * @param date 传入日期
     */
     @action async getScreenData(type: PageDateSelect,date?:Date) {

        // 获取左上部分
        this.screenData.purchaseNum=await getPurchaseNumData(type,date);
        this.screenData.purchaseNumPie= await getPurchaseNumChart(type,date);
        this.screenData.materialPie= await getMaterialPieChart(type,date);
        this.screenData.purchaseTypePie= await getPurchaseTypePieChart(type,date);
        this.screenData.materialTop10Column=await  getMaterialColumnChart(type,date);
        this.screenData.priceTop10Column=await  getMaterialLineChart(type,date);
        return  this.screenData;
    }




}
export default PurchaseGood;
